﻿//--------------------------------------------------------------------------
// 
//  Copyright (c) Chili Software.  All rights reserved. 
// 
//  File: IConcurrencyManager.cs
//
//  Description: Offers methods for a concurrency mechanism.
// 
//--------------------------------------------------------------------------

using System;
using Chili.Opf3.Storages;

namespace Chili.Opf3.Concurrency
{
	/// <summary>
	/// Interface implemented by classes that validate an object against the storage.
	/// </summary>
	/// <remarks>
	/// This interface is implemented by classes that validate an object against the storage.
	/// They check if somebody else changed the object in the meantime (while it has been in memory)
	/// and inform the <see cref="Opf3.ObjectContext">ObjectContext</see> whether a problem has
	/// been encountered.
	/// A class that implements this interface is the 
	/// <see cref="Opf3.Concurrency.Md5.Md5ConcurrencyManager">Md5ConcurrencyManager</see>.
	/// </remarks>
	public interface IConcurrencyManager
	{
		/// <summary>
		/// Invoked before the update operation of the object.
		/// </summary>
		/// <param name="obj">Persistent object that is validated.</param>
		/// <param name="e">EventArgs of the current routine.</param>
		void OnBeforeUpdate<T>(T obj, ConcurrencyManagerEventArgs e);

		/// <summary>
		/// Invoked after the update operation of the object.
		/// </summary>
		/// <param name="obj">Persistent object that is validated.</param>
		/// <param name="e">EventArgs of the current routine.</param>
		void OnAfterUpdate<T>(T obj, ConcurrencyManagerEventArgs e);

		/// <summary>
		/// Invoked before the insert operation of the object.
		/// </summary>
		/// <param name="obj">Persistent object that is validated.</param>
		/// <param name="e">EventArgs of the current routine.</param>
		void OnBeforeInsert<T>(T obj, ConcurrencyManagerEventArgs e);

		/// <summary>
		/// Invoked after the insert operation of the object.
		/// </summary>
		/// <param name="obj">Persistent object that is validated.</param>
		/// <param name="e">EventArgs of the current routine.</param>
		void OnAfterInsert<T>(T obj, ConcurrencyManagerEventArgs e);

		/// <summary>
		/// Invoked before the delete operation of the object.
		/// </summary>
		/// <param name="obj">Persistent object that is validated.</param>
		/// <param name="e">EventArgs of the current routine.</param>
		void OnBeforeDelete<T>(T obj, ConcurrencyManagerEventArgs e);

		/// <summary>
		/// Invoked after the load operation of the object.
		/// </summary>
		/// <param name="obj">Persistent object that is validated.</param>
		/// <param name="e">EventArgs of the current routine.</param>
		void OnAfterLoad<T>(T obj, ConcurrencyManagerEventArgs e);
	}
}
